home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 January: Mac OS SDK / Dev.CD Jan 96 SDK / Dev.CD Jan 96 SDK1.toast / Development Kits (Disc 1) / AOCE / Development Tools / Sample Code / Catalog Service Access Module / DTS Sample CSAM / Src / GetPABFSSpecCB.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-08-27  |  2.6 KB  |  111 lines  |  [TEXT/KAHL]

  1. /*                                GetPABFSSpecCB.c                                */
  2. /*
  3.  * GetPABFSSpecCB.c
  4.  * Copyright © 1992-93 Apple Computer Inc. All Rights Reserved.
  5.  *
  6.  * This is a callback function that AddDirectory uses to build a FSSpec that
  7.  * specifies the requested personal address catalog. Note that it must be called
  8.  * at a time when memory may be allocated.
  9.  */
  10. #include "DTSSampleCSAM.h"
  11.  
  12. pascal Boolean
  13. GetPABFSSpecCB(
  14.         FSSpec                *pabSpec,
  15.         const Attribute        *thisAttribute
  16.     )
  17. {
  18.         OSErr                status;
  19.         AliasHandle            alias;
  20.         Boolean                wasChanged;
  21.         THz                    oldZone;
  22.         
  23.         alias = NULL;
  24.         status = (pabSpec != NULL) ? noErr : nilHandleErr;
  25.         LogStatusX('GPAB', status, "\pNull pabSpec handle");
  26.         if (status == noErr
  27.          && thisAttribute->value.tag != typeBinary) {
  28.             status = paramErr;
  29.             Audit(
  30.                 GetAuditPtr(kCSAMCreatorID),
  31.                 'GPAB',
  32.                 AuditFormat2(kAuditFormatHex, kAuditFormatString),
  33.                 thisAttribute->value.tag,
  34.                 "\pNeed binary attribute"
  35.             );
  36.         }
  37.         if (status == noErr) {
  38.             Audit(
  39.                 GetAuditPtr(kCSAMCreatorID),
  40.                 'Pt2H',
  41.                 AuditFormat3(
  42.                     kAuditFormatUnsigned,
  43.                     kAuditFormatAddress,
  44.                     kAuditFormatString
  45.                 ),
  46.                 thisAttribute->value.dataLength,
  47.                 &alias,
  48.                 "\pPtrToHand"
  49.             );
  50.             /*
  51.              * We need a blob of temporary memory for
  52.              * ResolveAlias: make sure it's in the
  53.              * system heap; otherwise we can get
  54.              * a memFull error.
  55.              */
  56.             oldZone = GetZone();
  57.             SetZone(SystemZone());
  58.             LogStatusX('Zone', MemError(), "\pSetZone(SystemZone))");
  59.             status = PtrToHand(
  60.                         thisAttribute->value.bytes,
  61.                         (Handle *) &alias,
  62.                         thisAttribute->value.dataLength
  63.                     );
  64.             SetZone(oldZone);
  65.             LogStatusX('Zone', MemError(), "\pSetZone(oldZone))");
  66.             if (status != noErr) {
  67.                 Audit(
  68.                     GetAuditPtr(kCSAMCreatorID),
  69.                     'GPAB',
  70.                     AuditFormat3(
  71.                         kAuditFormatSigned,
  72.                         kAuditFormatUnsigned,
  73.                         kAuditFormatString
  74.                     ),
  75.                     (signed long) status,
  76.                     thisAttribute->value.dataLength,
  77.                     "\pPtrToHand"
  78.                 );
  79.             }
  80.         }
  81.         if (status == noErr) {
  82. Audit(GetAuditPtr(kCSAMCreatorID), 'GPAB', kAuditFormatString, "\pResolving Alias");
  83.             status = ResolveAlias(NULL, alias, pabSpec, &wasChanged);
  84.             LogStatusX('GPAB', status, "\pResolveAlias");
  85.         }
  86.         if (alias != NULL) {
  87.             DisposHandle((Handle) alias);
  88.             if (status == noErr) {
  89.                 status = MemError();
  90.                 LogStatusX('GPAB', status, "\pDisposHandle");
  91.             }
  92.         }
  93.         /*
  94.          * What do we do with status? It's all dressed up with
  95.          * nowhere to go.
  96.          */
  97.         if (status != noErr)
  98.             pabSpec->vRefNum = 0;
  99. Audit(
  100.     GetAuditPtr(kCSAMCreatorID),
  101.     'GPAB',
  102.     AuditFormat2(
  103.         kAuditFormatSigned,
  104.         kAuditFormatString
  105.     ),
  106.     (signed long) pabSpec->vRefNum,
  107.     "\pvRefNum (0 bad)"
  108. );
  109.         return (TRUE);
  110. }
  111.